package sample;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        URL.setURLStreamHandlerFactory(new MyURLStreamHandlerFactory());
//        URL url=new URL("myapp://OneTab.html");
//        MyURLConnection con=new MyURLConnection(url);
//        con.loadImage();
//        con.loadhtml(con.imgPath);
//        final InputStream stream;

//        stream = Main.class.getResourceAsStream(con.imgPath);
//        System.out.println("Stream = " + stream);
        int i;
        //i=con.getContentLength();
        //System.out.println(i);
//        Parent root = FXMLLoader.load(getClass().getResource(con.imgPath));
//        //Parent root1=
//        primaryStage.setTitle("Hello World");
//        primaryStage.setScene(new Scene(root, 300, 275));
//        primaryStage.show();



        primaryStage.setTitle("WebView test");

        WebView browser = new WebView();
        WebEngine engine = browser.getEngine();
//        String url1 = Main.class.getResource(con.imgPath).toExternalForm();
//        System.out.println(url1);
        engine.load("myapp:/OneTab.html");//myapp://OneTab.html

        StackPane sp = new StackPane();
        sp.getChildren().add(browser);

        Scene root = new Scene(sp);

        primaryStage.setScene(root);
        primaryStage.show();
    }


    public static void main(String[] args) throws IOException {
        launch(args);
//        URL.setURLStreamHandlerFactory(new MyURLStreamHandlerFactory());
//        URL url=new URL("myapp://C:/Users/94080/Desktop/OneTab.html");
//        MyURLConnection con=new MyURLConnection(url);
//        con.loadImage();

    }
}

